﻿using System;
using System.Linq;
using System.Text;
using System.Windows;
using FrameWork.Services;
using System.Windows.Data;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace AncheStart.Converter
{
    [ValueConversion(typeof(int), typeof(Visibility))]
    public class ColumnVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var columnCode = (string)parameter;
            var variableInfo = GlobalConstant.ColumnInfos.Where(p => !string.IsNullOrEmpty(p.ColumnCode) && p.ColumnCode.Equals(parameter)).FirstOrDefault();
            return variableInfo.Visible ? Visibility.Visible : Visibility.Hidden;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
